home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / himetr1r / frmmain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-08-18  |  61.9 KB  |  1,686 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
  3. Object = "{54F463F3-0135-11D2-8D52-00C04FA4EE99}#7.2#0"; "VBALTBAR.OCX"
  4. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  5. Begin VB.Form frmMain 
  6.    Caption         =   "Developers Code Book"
  7.    ClientHeight    =   6855
  8.    ClientLeft      =   1605
  9.    ClientTop       =   2145
  10.    ClientWidth     =   8235
  11.    BeginProperty Font 
  12.       Name            =   "Tahoma"
  13.       Size            =   8.25
  14.       Charset         =   0
  15.       Weight          =   400
  16.       Underline       =   0   'False
  17.       Italic          =   0   'False
  18.       Strikethrough   =   0   'False
  19.    EndProperty
  20.    Icon            =   "frmMain.frx":0000
  21.    LinkTopic       =   "Form1"
  22.    ScaleHeight     =   6855
  23.    ScaleWidth      =   8235
  24.    Begin prjDevBook.ctlData ctlData1 
  25.       Height          =   2655
  26.       Left            =   3360
  27.       TabIndex        =   10
  28.       Top             =   720
  29.       Width           =   3735
  30.       _ExtentX        =   6588
  31.       _ExtentY        =   4683
  32.    End
  33.    Begin prjDevBook.ctlFavourites ctlFavourites1 
  34.       Height          =   1935
  35.       Left            =   120
  36.       TabIndex        =   3
  37.       Top             =   4200
  38.       Width           =   6615
  39.       _ExtentX        =   11668
  40.       _ExtentY        =   3413
  41.    End
  42.    Begin VB.Timer tmrDragTimer 
  43.       Enabled         =   0   'False
  44.       Interval        =   100
  45.       Left            =   3240
  46.       Top             =   2280
  47.    End
  48.    Begin ComctlLib.ProgressBar pgb 
  49.       Height          =   255
  50.       Left            =   1920
  51.       TabIndex        =   4
  52.       Top             =   5280
  53.       Visible         =   0   'False
  54.       Width           =   1575
  55.       _ExtentX        =   2778
  56.       _ExtentY        =   450
  57.       _Version        =   327682
  58.       Appearance      =   1
  59.    End
  60.    Begin MSComDlg.CommonDialog cmdDialog 
  61.       Left            =   480
  62.       Top             =   5640
  63.       _ExtentX        =   847
  64.       _ExtentY        =   847
  65.       _Version        =   393216
  66.    End
  67.    Begin VB.TextBox txtTemp 
  68.       Height          =   375
  69.       Left            =   3480
  70.       MultiLine       =   -1  'True
  71.       TabIndex        =   9
  72.       Top             =   5640
  73.       Visible         =   0   'False
  74.       Width           =   2055
  75.    End
  76.    Begin VB.ComboBox cboFind 
  77.       Height          =   315
  78.       Left            =   1440
  79.       TabIndex        =   8
  80.       Text            =   "Find..."
  81.       Top             =   5640
  82.       Width           =   1935
  83.    End
  84.    Begin VB.PictureBox picToolbar 
  85.       BorderStyle     =   0  'None
  86.       BeginProperty Font 
  87.          Name            =   "Tahoma"
  88.          Size            =   9
  89.          Charset         =   0
  90.          Weight          =   400
  91.          Underline       =   0   'False
  92.          Italic          =   0   'False
  93.          Strikethrough   =   0   'False
  94.       EndProperty
  95.       Height          =   615
  96.       Left            =   0
  97.       ScaleHeight     =   615
  98.       ScaleWidth      =   8295
  99.       TabIndex        =   5
  100.       Top             =   0
  101.       Width           =   8295
  102.       Begin vbalTBar.cToolbarHost tbhMenu 
  103.          Height          =   255
  104.          Left            =   3840
  105.          TabIndex        =   7
  106.          Top             =   120
  107.          Width           =   495
  108.          _ExtentX        =   873
  109.          _ExtentY        =   450
  110.       End
  111.       Begin vbalTBar.cToolbarHost tbhMain 
  112.          Height          =   255
  113.          Left            =   3000
  114.          TabIndex        =   6
  115.          Top             =   0
  116.          Width           =   615
  117.          _ExtentX        =   1085
  118.          _ExtentY        =   450
  119.       End
  120.       Begin vbalTBar.cToolbar tbrMenu 
  121.          Left            =   2280
  122.          Top             =   120
  123.          _ExtentX        =   1720
  124.          _ExtentY        =   450
  125.       End
  126.       Begin vbalTBar.cToolbar tbrMain 
  127.          Left            =   1440
  128.          Top             =   120
  129.          _ExtentX        =   1296
  130.          _ExtentY        =   450
  131.       End
  132.       Begin vbalTBar.cReBar rbrMain 
  133.          Left            =   0
  134.          Top             =   0
  135.          _ExtentX        =   2143
  136.          _ExtentY        =   661
  137.       End
  138.    End
  139.    Begin VB.PictureBox picSplit 
  140.       BackColor       =   &H80000003&
  141.       BorderStyle     =   0  'None
  142.       BeginProperty Font 
  143.          Name            =   "Tahoma"
  144.          Size            =   9
  145.          Charset         =   0
  146.          Weight          =   400
  147.          Underline       =   0   'False
  148.          Italic          =   0   'False
  149.          Strikethrough   =   0   'False
  150.       EndProperty
  151.       Height          =   4800
  152.       Left            =   3000
  153.       MousePointer    =   9  'Size W E
  154.       ScaleHeight     =   4800
  155.       ScaleWidth      =   75
  156.       TabIndex        =   2
  157.       Top             =   420
  158.       Visible         =   0   'False
  159.       Width           =   72
  160.    End
  161.    Begin ComctlLib.StatusBar stbBar 
  162.       Align           =   2  'Align Bottom
  163.       Height          =   255
  164.       Left            =   0
  165.       TabIndex        =   1
  166.       Top             =   6600
  167.       Width           =   8235
  168.       _ExtentX        =   14526
  169.       _ExtentY        =   450
  170.       SimpleText      =   ""
  171.       _Version        =   327682
  172.       BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
  173.          NumPanels       =   1
  174.          BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  175.             Key             =   ""
  176.             Object.Tag             =   ""
  177.          EndProperty
  178.       EndProperty
  179.    End
  180.    Begin ComctlLib.TreeView tvwItems 
  181.       Height          =   3255
  182.       Left            =   120
  183.       TabIndex        =   0
  184.       Top             =   480
  185.       Width           =   2385
  186.       _ExtentX        =   4207
  187.       _ExtentY        =   5741
  188.       _Version        =   327682
  189.       HideSelection   =   0   'False
  190.       Indentation     =   353
  191.       LabelEdit       =   1
  192.       LineStyle       =   1
  193.       Sorted          =   -1  'True
  194.       Style           =   7
  195.       ImageList       =   "imgIcons"
  196.       BorderStyle     =   1
  197.       Appearance      =   1
  198.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  199.          Name            =   "Tahoma"
  200.          Size            =   8.25
  201.          Charset         =   0
  202.          Weight          =   400
  203.          Underline       =   0   'False
  204.          Italic          =   0   'False
  205.          Strikethrough   =   0   'False
  206.       EndProperty
  207.       OLEDropMode     =   1
  208.    End
  209.    Begin ComctlLib.ImageList ilsMenu 
  210.       Left            =   4320
  211.       Top             =   3120
  212.       _ExtentX        =   1005
  213.       _ExtentY        =   1005
  214.       BackColor       =   12632256
  215.       ImageWidth      =   16
  216.       ImageHeight     =   16
  217.       MaskColor       =   12632256
  218.       _Version        =   327682
  219.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  220.          NumListImages   =   29
  221.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  222.             Picture         =   "frmMain.frx":014A
  223.             Key             =   ""
  224.          EndProperty
  225.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  226.             Picture         =   "frmMain.frx":049C
  227.             Key             =   ""
  228.          EndProperty
  229.          BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  230.             Picture         =   "frmMain.frx":07EE
  231.             Key             =   ""
  232.          EndProperty
  233.          BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  234.             Picture         =   "frmMain.frx":0B40
  235.             Key             =   ""
  236.          EndProperty
  237.          BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  238.             Picture         =   "frmMain.frx":0E92
  239.             Key             =   ""
  240.          EndProperty
  241.          BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  242.             Picture         =   "frmMain.frx":11E4
  243.             Key             =   ""
  244.          EndProperty
  245.          BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  246.             Picture         =   "frmMain.frx":1536
  247.             Key             =   ""
  248.          EndProperty
  249.          BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  250.             Picture         =   "frmMain.frx":1888
  251.             Key             =   ""
  252.          EndProperty
  253.          BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  254.             Picture         =   "frmMain.frx":1BDA
  255.             Key             =   ""
  256.          EndProperty
  257.          BeginProperty ListImage10 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  258.             Picture         =   "frmMain.frx":1F2C
  259.             Key             =   ""
  260.          EndProperty
  261.          BeginProperty ListImage11 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  262.             Picture         =   "frmMain.frx":227E
  263.             Key             =   ""
  264.          EndProperty
  265.          BeginProperty ListImage12 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  266.             Picture         =   "frmMain.frx":25D0
  267.             Key             =   ""
  268.          EndProperty
  269.          BeginProperty ListImage13 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  270.             Picture         =   "frmMain.frx":2922
  271.             Key             =   ""
  272.          EndProperty
  273.          BeginProperty ListImage14 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  274.             Picture         =   "frmMain.frx":2C74
  275.             Key             =   ""
  276.          EndProperty
  277.          BeginProperty ListImage15 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  278.             Picture         =   "frmMain.frx":2FC6
  279.             Key             =   ""
  280.          EndProperty
  281.          BeginProperty ListImage16 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  282.             Picture         =   "frmMain.frx":3318
  283.             Key             =   ""
  284.          EndProperty
  285.          BeginProperty ListImage17 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  286.             Picture         =   "frmMain.frx":366A
  287.             Key             =   ""
  288.          EndProperty
  289.          BeginProperty ListImage18 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  290.             Picture         =   "frmMain.frx":39BC
  291.             Key             =   ""
  292.          EndProperty
  293.          BeginProperty ListImage19 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  294.             Picture         =   "frmMain.frx":3D0E
  295.             Key             =   ""
  296.          EndProperty
  297.          BeginProperty ListImage20 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  298.             Picture         =   "frmMain.frx":4060
  299.             Key             =   ""
  300.          EndProperty
  301.          BeginProperty ListImage21 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  302.             Picture         =   "frmMain.frx":43B2
  303.             Key             =   ""
  304.          EndProperty
  305.          BeginProperty ListImage22 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  306.             Picture         =   "frmMain.frx":4704
  307.             Key             =   ""
  308.          EndProperty
  309.          BeginProperty ListImage23 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  310.             Picture         =   "frmMain.frx":4A56
  311.             Key             =   ""
  312.          EndProperty
  313.          BeginProperty ListImage24 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  314.             Picture         =   "frmMain.frx":4DA8
  315.             Key             =   ""
  316.          EndProperty
  317.          BeginProperty ListImage25 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  318.             Picture         =   "frmMain.frx":50FA
  319.             Key             =   ""
  320.          EndProperty
  321.          BeginProperty ListImage26 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  322.             Picture         =   "frmMain.frx":544C
  323.             Key             =   ""
  324.          EndProperty
  325.          BeginProperty ListImage27 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  326.             Picture         =   "frmMain.frx":579E
  327.             Key             =   ""
  328.          EndProperty
  329.          BeginProperty ListImage28 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  330.             Picture         =   "frmMain.frx":5AF0
  331.             Key             =   ""
  332.          EndProperty
  333.          BeginProperty ListImage29 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  334.             Picture         =   "frmMain.frx":5E42
  335.             Key             =   ""
  336.          EndProperty
  337.       EndProperty
  338.    End
  339.    Begin ComctlLib.ImageList imgPics 
  340.       Left            =   3000
  341.       Top             =   3120
  342.       _ExtentX        =   1005
  343.       _ExtentY        =   1005
  344.       BackColor       =   -2147483643
  345.       ImageWidth      =   16
  346.       ImageHeight     =   16
  347.       MaskColor       =   12632256
  348.       _Version        =   327682
  349.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  350.          NumListImages   =   13
  351.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  352.             Picture         =   "frmMain.frx":6196
  353.             Key             =   "CLIP"
  354.          EndProperty
  355.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  356.             Picture         =   "frmMain.frx":64E8
  357.             Key             =   "COLOUR"
  358.          EndProperty
  359.          BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  360.             Picture         =   "frmMain.frx":683A
  361.             Key             =   "COPY"
  362.          EndProperty
  363.          BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  364.             Picture         =   "frmMain.frx":6B8C
  365.             Key             =   "CUT"
  366.          EndProperty
  367.          BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  368.             Picture         =   "frmMain.frx":6EDE
  369.             Key             =   "DELETE"
  370.          EndProperty
  371.          BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  372.             Picture         =   "frmMain.frx":7230
  373.             Key             =   "FAVOURITES"
  374.          EndProperty
  375.          BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  376.             Picture         =   "frmMain.frx":7582
  377.             Key             =   "FIND"
  378.          EndProperty
  379.          BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  380.             Picture         =   "frmMain.frx":78D4
  381.             Key             =   "NEW"
  382.          EndProperty
  383.          BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  384.             Picture         =   "frmMain.frx":7C26
  385.             Key             =   "NEXT"
  386.          EndProperty
  387.          BeginProperty ListImage10 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  388.             Picture         =   "frmMain.frx":7F78
  389.             Key             =   "PASTE"
  390.          EndProperty
  391.          BeginProperty ListImage11 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  392.             Picture         =   "frmMain.frx":82CA
  393.             Key             =   "PREVIOUS"
  394.          EndProperty
  395.          BeginProperty ListImage12 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  396.             Picture         =   "frmMain.frx":861C
  397.             Key             =   "PRINT"
  398.          EndProperty
  399.          BeginProperty ListImage13 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  400.             Picture         =   "frmMain.frx":896E
  401.             Key             =   "SELECTALL"
  402.          EndProperty
  403.       EndProperty
  404.    End
  405.    Begin VB.Image imgSplitter 
  406.       Height          =   4785
  407.       Left            =   2625
  408.       MousePointer    =   9  'Size W E
  409.       Top             =   360
  410.       Width           =   195
  411.    End
  412.    Begin ComctlLib.ImageList imgIcons 
  413.       Left            =   3600
  414.       Top             =   3120
  415.       _ExtentX        =   1005
  416.       _ExtentY        =   1005
  417.       BackColor       =   -2147483643
  418.       ImageWidth      =   16
  419.       ImageHeight     =   16
  420.       MaskColor       =   12632256
  421.       _Version        =   327682
  422.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  423.          NumListImages   =   6
  424.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  425.             Picture         =   "frmMain.frx":8CC0
  426.             Key             =   "CLASS"
  427.          EndProperty
  428.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  429.             Picture         =   "frmMain.frx":8F82
  430.             Key             =   "OPEN"
  431.          EndProperty
  432.          BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  433.             Picture         =   "frmMain.frx":92D4
  434.             Key             =   "CLOSED"
  435.          EndProperty
  436.          BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  437.             Picture         =   "frmMain.frx":9626
  438.             Key             =   "CODE"
  439.          EndProperty
  440.          BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  441.             Picture         =   "frmMain.frx":990C
  442.             Key             =   "MODULE"
  443.          EndProperty
  444.          BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  445.             Picture         =   "frmMain.frx":9BFE
  446.             Key             =   "ROOT"
  447.          EndProperty
  448.       EndProperty
  449.    End
  450. Attribute VB_Name = "frmMain"
  451. Attribute VB_GlobalNameSpace = False
  452. Attribute VB_Creatable = False
  453. Attribute VB_PredeclaredId = True
  454. Attribute VB_Exposed = False
  455. '----------------------------------------
  456. '- Name: Sam Huggill
  457. '- Email: sam@vbsquare.com
  458. '- Web: http://www.vbsquare.com/
  459. '- Company: Lighthouse Internet Solutions
  460. '- Date/Time: 14/08/99 11:33:00
  461. '----------------------------------------
  462. '- Notes:   Main form that operates most of
  463. '           the UI
  464. '----------------------------------------
  465. Option Explicit
  466. Public VBInstance As VBIDE.VBE
  467. Public Connect As Connect
  468. Private WithEvents m_cMenu As cPopupMenu    ' File menu
  469. Attribute m_cMenu.VB_VarHelpID = -1
  470. Private WithEvents m_cTree As cPopupMenu    ' Treeview context menu
  471. Attribute m_cTree.VB_VarHelpID = -1
  472. Private mbSplitting As Boolean    '// Are we splitting?
  473. Private m_blnShowCPL As Boolean
  474. Private Const lVSplitLimit As Long = 1500   '// Splitter side limits
  475. Private m_nodNode As Node   '// Node handler
  476. Private miClipBoardFormat As Integer '// Custom Clipboard format
  477. Private mnDragNode As Node  '// Dragged Node
  478. Private miScrollDir As Integer '// Scroll direction
  479. Private m_blnControl As Boolean    '// Show the control panel
  480. Private m_blnDBLoaded As Boolean
  481. Private Sub cboFind_KeyUp(KeyCode As Integer, Shift As Integer)
  482.     On Error GoTo vbErrHand
  483.     ' Detect the return key
  484.     If KeyCode = vbKeyReturn Then
  485.         ' Find the text
  486.         frmFind.optEntire = True
  487.         frmFind.FindItem cboFind.Text, tvwItems
  488.         AddQuickFind cboFind.Text
  489.         tvwItems.SetFocus
  490.         DoEvents
  491.         Unload frmFind
  492.         
  493.     End If
  494.     Exit Sub
  495. vbErrHand:
  496.     WriteError Err.Number, Err.Description, "cboFind_KeyUp", Now, App.Path & "\err.log"
  497.     MsgBox Err.Description, vbCritical + vbOKOnly, "cboFind_KeyUp"
  498. End Sub
  499. Private Sub ctlData1_GotFocus()
  500.     Dim Control As Object
  501.     On Error Resume Next
  502.     ' Loop through all the controls and make sure
  503.     ' that the edit box keeps the focus and therefore
  504.     ' will accept tabs
  505.     For Each Control In Controls
  506.         Control.TabStop = False
  507.     Next Control
  508. End Sub
  509. Private Sub Form_Load()
  510.     On Error GoTo vbErrHand
  511.     m_blnDBLoaded = False
  512.     ' Open the DB
  513.     If modData.OpenDB(modMain.LastDB) Then
  514.         m_blnDBLoaded = True
  515.         
  516.         Me.Caption = Me.Caption & " " & modMain.LastDB
  517.         
  518.         ' Load the items into the tree
  519.         modData.FillTree tvwItems
  520.                
  521.         QuickFind cboFind
  522.         ' Call our startup proc
  523.         StartUp
  524.     End If
  525.     Exit Sub
  526. vbErrHand:
  527.     WriteError Err.Number, Err.Description, "Form_Load", Now, App.Path & "\err.log"
  528.     MsgBox Err.Description, vbCritical + vbOKOnly, "Form_Load"
  529. End Sub
  530. Private Sub StartUp()
  531.     Dim ctl As Control
  532.     Dim intCount As Integer
  533.     On Error GoTo vbErrHand
  534.     CentreForm Me
  535.     '// Get out registry settings
  536.     GetSettings
  537.     '// Show/Hide our control panel
  538.     ctlData1.Initalize
  539.     ctlFavourites1.Initalize
  540.     InitColorize
  541.     InitToolbar
  542.     ShowProgressInStatusBar True
  543.     ShowCPL m_blnControl
  544.     miClipBoardFormat = RegisterClipboardFormat("DCB")
  545.     '// Make the tree a reasonable width
  546.     SizeControls (tvwItems.Width * 3) / 2
  547.     Exit Sub
  548. vbErrHand:
  549.     WriteError Err.Number, Err.Description, "Startup", Now, App.Path & "\err.log"
  550.     MsgBox Err.Description, vbCritical + vbOKOnly, "Startup"
  551. End Sub
  552. Private Sub Form_Resize()
  553.     '// Resize our controls
  554.     SizeControls tvwItems.Width
  555. End Sub
  556. Private Sub Form_Unload(Cancel As Integer)
  557. '    On Error GoTo vbErrHand
  558.     UnloadMe
  559.     '// Free up some memory here...
  560.     If Not (m_cMenu Is Nothing) Then
  561.         m_cMenu.Clear
  562.         m_cMenu.DestroySubClass
  563.     End If
  564.     If Not (m_cTree Is Nothing) Then
  565.         m_cTree.Clear
  566.         m_cTree.DestroySubClass
  567.     End If
  568.     If Not (tbrMain Is Nothing) Then
  569.         tbrMain.DestroyToolBar
  570.     End If
  571.     If Not (tbrMenu Is Nothing) Then
  572.         tbrMenu.DestroyToolBar
  573.     End If
  574.     If Not (rbrMain Is Nothing) Then
  575.         rbrMain.RemoveAllRebarBands
  576.         rbrMain.DestroyRebar
  577.     End If
  578.     Set m_cMenu = Nothing
  579.     Set m_cTree = Nothing
  580.     '// Free up memory in the DB module
  581.     Call modData.SetNothing
  582.     Exit Sub
  583. vbErrHand:
  584.     WriteError Err.Number, Err.Description, "Form_Unload", Now, App.Path & "\err.log"
  585.     MsgBox Err.Description, vbCritical + vbOKOnly, "Form_Unload"
  586. End Sub
  587. Private Sub imgSplitter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  588.     '// Initalize the splitting action
  589.     '// Thanks to Chris Eastwood for this (and many other things)
  590.     With imgSplitter
  591.         picSplit.Move .left, .tOp, .Width \ 2, .Height - 20
  592.     End With
  593.     picSplit.Visible = True
  594.     mbSplitting = True
  595. End Sub
  596. Private Sub imgSplitter_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  597.     Dim sglPos As Single
  598.     'Check if we are splitting: If so show the splitter
  599.     'bar and move the controls
  600.     If mbSplitting Then
  601.         sglPos = X + imgSplitter.left
  602.         If sglPos < lVSplitLimit Then
  603.             picSplit.left = lVSplitLimit
  604.         ElseIf sglPos > Me.Width - lVSplitLimit Then
  605.             picSplit.left = Me.Width - lVSplitLimit
  606.         Else
  607.             picSplit.left = sglPos
  608.         End If
  609.     End If
  610. End Sub
  611. Private Sub imgSplitter_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  612.     '// Resize the form and hide the splitter bar
  613.     SizeControls picSplit.left
  614.     picSplit.Visible = False
  615.     mbSplitting = False
  616. End Sub
  617. Private Sub m_cMenu_Click(ItemNumber As Long)
  618.     On Error GoTo vbErrHand
  619.     '// Handles the menu items
  620.     Select Case m_cMenu.ItemKey(ItemNumber)
  621.         Case "NEW"
  622.             modFiles.NewDB ShowFileDialog(eSave, "", "Save New DB As..", "Access Database (*.mdb)|*.mdb| All Files (*.*)|*.*|")
  623.         Case "CPL"
  624.             ShowCPL Not (ctlFavourites1.Visible)
  625.         Case "OPEN"
  626.             modFiles.OpenDB ShowFileDialog(eOpen, "", "Open Database", "Database|*.mdb")
  627.             Me.Caption = "Developers Code Book " & modData.DBName
  628.         Case "FAVOURITES"
  629.             If tvwItems.SelectedItem Is Nothing Then
  630.                 MsgBox "No item selected.", vbOKOnly + vbInformation
  631.                 Exit Sub
  632.             End If
  633.             If tvwItems.SelectedItem.Key <> "ROOT" Then
  634.                 ctlFavourites1.AddItem tvwItems
  635.             End If
  636.         Case "README"
  637.             ShellExecute 0&, vbNullString, App.Path & "\readme.txt", vbNullString, vbNullString, vbNormalFocus
  638.         Case "NET"
  639.             ShellExecute 0&, vbNullString, "http://www.programmerz.com/vb/dev/", vbNullString, vbNullString, vbNormalFocus
  640.         Case "REMOVE"
  641.             If tvwItems.SelectedItem Is Nothing Then
  642.                 MsgBox "No item selected.", vbOKOnly + vbInformation
  643.                 Exit Sub
  644.             End If
  645.             If tvwItems.SelectedItem.Key <> "ROOT" Then
  646.                 ctlFavourites1.DeleteItem tvwItems
  647.             End If
  648.         Case "RENAME"
  649.             tvwItems.StartLabelEdit
  650.         Case "UNDO"
  651.             ctlData1.Undo
  652.         Case "CUT"
  653.             ctlData1.Cut
  654.         Case "COPY"
  655.             ctlData1.Copy
  656.         Case "PASTE"
  657.             ctlData1.Paste
  658.         Case "SELECTALL"
  659.             ctlData1.SelectAll
  660.         Case "PROPERTIES"
  661.             Dim mNode As Node
  662.             Set mNode = tvwItems.SelectedItem
  663.             If mNode Is Nothing Then
  664.                 MsgBox "No Item selected."
  665.                 Exit Sub
  666.             End If
  667.             If mNode.Key = "ROOT" Then
  668.                 MsgBox "Properties for the root node cannot be viewed."
  669.                 Exit Sub
  670.             End If
  671.             frmAdd.Caption = "Properties for: " & tvwItems.SelectedItem.Text
  672.             frmAdd.cmdAdd.Visible = False
  673.             frmAdd.cmdApply.Visible = True
  674.             frmAdd.txtDescription = tvwItems.SelectedItem.Text
  675.             frmAdd.txtNotes = ctlData1.PlainNotes
  676.             frmAdd.cmdApply.Default = True
  677.             frmAdd.optLevel(0).Enabled = False
  678.             frmAdd.optLevel(1).Enabled = False
  679.             Select Case g_strVersion
  680.                 Case "VB4 16"
  681.                     frmAdd.cboVersion.ListIndex = 0
  682.                 Case "VB4 32"
  683.                     frmAdd.cboVersion.ListIndex = 1
  684.                 Case "VB5"
  685.                     frmAdd.cboVersion.ListIndex = 2
  686.                 Case "VB6"
  687.                     frmAdd.cboVersion.ListIndex = 3
  688.                 Case Else
  689.             End Select
  690.             Select Case g_strLevel
  691.                 Case "Beginner"
  692.                     frmAdd.cboLevel.ListIndex = 0
  693.                 Case "Intermediate"
  694.                     frmAdd.cboLevel.ListIndex = 1
  695.                 Case "Advanced"
  696.                     frmAdd.cboLevel.ListIndex = 2
  697.                 Case Else
  698.             End Select
  699.             frmAdd.Show vbModal
  700.         Case "OPTIONS"
  701.             frmOptions.Show vbModal
  702.         Case "ABOUT"
  703.             frmAbout.Show vbModal
  704.         Case "EXIT" 'Exit
  705.             Unload Me
  706.             'End
  707.         Case Else
  708.     End Select
  709.     Set mNode = Nothing
  710.     Exit Sub
  711. vbErrHand:
  712.     WriteError Err.Number, Err.Description, "m_cMenu_Click", Now, App.Path & "\err.log"
  713.     MsgBox Err.Description, vbCritical + vbOKOnly, "m_cMenu_Click"
  714. End Sub
  715. Private Sub m_cTree_Click(ItemNumber As Long)
  716.     Dim obj As VBIDE.VBComponent
  717.     On Error Resume Next
  718. ' Handles the treeview's menu items
  719.     Select Case m_cTree.ItemKey(ItemNumber)
  720.         Case "ADD"
  721.             frmAdd.Show vbModal
  722.         Case "FOLDER"
  723.             modData.AddFolder tvwItems, ctlData1
  724.         Case "IMPORT"
  725.             modData.Key = tvwItems.SelectedItem.Key
  726.             modData.ImportCodeItems tvwItems
  727.         Case "DCB"
  728.             modFiles.ExportFile tvwItems.SelectedItem.Key, tvwItems, ctlData1
  729.             modData.SelectItem tvwItems.SelectedItem.Key, ctlData1
  730.             
  731.         Case "NEWMOD" ' Import the current code
  732.             If Not (Me.VBInstance Is Nothing) Then
  733.                 
  734.                 Set obj = VBInstance.ActiveVBProject.VBComponents.Add(vbext_ct_StdModule)
  735.                 obj.CodeModule.AddFromString ctlData1.PlainCode
  736.                 obj.Name = tvwItems.SelectedItem.Text
  737.                 obj.Activate
  738.                 
  739.             End If
  740.             
  741.         Case "NEWCLS"
  742.             If Not (Me.VBInstance Is Nothing) Then
  743.             
  744.                 Set obj = VBInstance.ActiveVBProject.VBComponents.Add(vbext_ct_ClassModule)
  745.                 obj.CodeModule.AddFromFile ctlData1.PlainCode
  746.                 obj.Name = tvwItems.SelectedItem.Text
  747.                 obj.Activate
  748.             
  749.             End If
  750.         Case "DEL"
  751.             If tvwItems.SelectedItem Is Nothing Then
  752.                 MsgBox "No item selected.", vbOKOnly + vbInformation
  753.                 Exit Sub
  754.             End If
  755.             modData.Key = tvwItems.SelectedItem.Key
  756.             modData.DeleteNode tvwItems
  757.         Case "HTML"
  758.             SourceToHTML ctlData1.Code
  759.         Case "ADDFAVS"
  760.             If tvwItems.SelectedItem Is Nothing Then
  761.                 MsgBox "No item selected.", vbOKOnly + vbInformation
  762.                 Exit Sub
  763.             End If
  764.             If tvwItems.SelectedItem.Key <> "ROOT" Then
  765.                 ctlFavourites1.AddItem tvwItems
  766.             End If
  767.         Case "REMFAVS"
  768.             If tvwItems.SelectedItem Is Nothing Then
  769.                 MsgBox "No item selected.", vbOKOnly + vbInformation
  770.                 Exit Sub
  771.             End If
  772.             If tvwItems.SelectedItem.Key <> "ROOT" Then
  773.                 ctlFavourites1.DeleteItem tvwItems
  774.             End If
  775.         Case "PROPS"
  776.             Dim mNode As Node
  777.             Set mNode = tvwItems.SelectedItem
  778.             If mNode Is Nothing Then
  779.                 MsgBox "No Item selected."
  780.                 Exit Sub
  781.             End If
  782.             If mNode.Key = "ROOT" Then
  783.                 MsgBox "Properties for the root node cannot be viewed."
  784.                 Exit Sub
  785.             End If
  786.             frmAdd.Caption = "Properties for: " & tvwItems.SelectedItem.Text
  787.             frmAdd.cmdAdd.Visible = False
  788.             frmAdd.cmdApply.Visible = True
  789.             frmAdd.txtDescription = tvwItems.SelectedItem.Text
  790.             frmAdd.txtNotes = ctlData1.PlainNotes
  791.             frmAdd.cmdApply.Default = True
  792.             frmAdd.optLevel(0).Enabled = False
  793.             frmAdd.optLevel(1).Enabled = False
  794.             Select Case g_strVersion
  795.                 Case "4 16"
  796.                     frmAdd.cboVersion.ListIndex = 0
  797.                 Case "4 32"
  798.                     frmAdd.cboVersion.ListIndex = 1
  799.                 Case "5"
  800.                     frmAdd.cboVersion.ListIndex = 2
  801.                 Case Else
  802.             End Select
  803.             Select Case g_strLevel
  804.                 Case "Beginner"
  805.                     frmAdd.cboLevel.ListIndex = 0
  806.                 Case "Intermediate"
  807.                     frmAdd.cboLevel.ListIndex = 1
  808.                 Case "Advanced"
  809.                     frmAdd.cboLevel.ListIndex = 2
  810.                 Case Else
  811.             End Select
  812.             frmAdd.Show vbModal
  813.         Case Else
  814.     End Select
  815.     Set mNode = Nothing
  816. End Sub
  817. Private Sub picToolbar_Resize()
  818.     '// Make sure we can see our toolbar
  819.     rbrMain.RebarSize
  820.     picToolbar.Height = rbrMain.RebarHeight * Screen.TwipsPerPixelY
  821. End Sub
  822. Private Sub rbrMain_HeightChanged(lNewHeight As Long)
  823.     picToolbar.Height = lNewHeight * Screen.TwipsPerPixelY
  824.     Form_Resize
  825. End Sub
  826. Private Sub tbrMain_ButtonClick(ByVal lButton As Long)
  827.     On Error GoTo vbErrHand
  828.     Dim lRet As Long
  829.     '// Handle button clicks
  830.     Select Case tbrMain.ButtonKey(lButton)
  831.         Case "UNDO"
  832.             If ctlData1.CanUndo Then
  833.                 ctlData1.Undo
  834.             End If
  835.         Case "UP"
  836.             MoveUp tvwItems
  837.         Case "DOWN"
  838.             MoveDown tvwItems
  839.         Case "NEW"
  840.             frmAdd.Show vbModal
  841.         Case "SAVE"
  842.             If tvwItems.SelectedItem Is Nothing Then Exit Sub
  843.             modData.Key = tvwItems.SelectedItem.Key
  844.             modData.Code = ctlData1.Code
  845.             modData.Example = ctlData1.Example
  846.             modData.Notes = ctlData1.Notes
  847.             modData.Description = ctlData1.Caption
  848.             modData.UpdateDB tvwItems
  849.         Case "DELETE"
  850.             If tvwItems.SelectedItem Is Nothing Then
  851.                 MsgBox "No item selected.", vbOKOnly + vbInformation
  852.                 Exit Sub
  853.             End If
  854.             modData.DeleteNode tvwItems
  855.         Case "COLOUR"
  856.             ctlData1.Colour
  857.         Case "FIND"
  858.             frmFind.Show vbModal
  859.         Case "ADDFAVS"
  860.             If tvwItems.SelectedItem Is Nothing Then
  861.                 MsgBox "No item selected.", vbOKOnly + vbInformation
  862.                 Exit Sub
  863.             End If
  864.             ctlFavourites1.AddItem tvwItems
  865.         Case "CUT"
  866.             ctlData1.Cut
  867.         Case "COPY"
  868.             ctlData1.Copy
  869.         Case "PASTE"
  870.             ctlData1.Paste
  871.         Case "SELECTALL"
  872.             ctlData1.SelectAll
  873.         Case "PRINT"
  874.             lRet = MsgBox("Are you sure you want to print:" & vbCrLf & ctlData1.Caption & "?", vbYesNo + vbInformation)
  875.             If lRet = vbNo Then Exit Sub
  876.             'Print It
  877.             ctlData1.PrintCode
  878.         Case Else
  879.     End Select
  880.     Exit Sub
  881. vbErrHand:
  882.     WriteError Err.Number, Err.Description, "tbrMain_ButtonClick", Now, App.Path & "\err.log"
  883.     MsgBox Err.Description, vbCritical + vbOKOnly, "tbrMain_ButtonClick"
  884. End Sub
  885. Private Sub tmrDragTimer_Timer()
  886.     Dim nHitNode As Node
  887.     Static lCount As Long
  888.     '
  889.     ' This timer has two functions :
  890.     '
  891.     ' 1 - It will scroll the TreeView when the user is dragging
  892.     '
  893.     ' 2 - It will auto-expand a node when the user drags over it for more than
  894.     '     half a second.
  895.     '
  896.     ' Both pieces of code stolen from the MDSN.
  897.     '
  898.     If mnDragNode Is Nothing Then
  899.         tmrDragTimer.Enabled = False
  900.         Exit Sub
  901.     End If
  902.     lCount = lCount + 1
  903.     If lCount > 10 Then
  904.         Set nHitNode = tvwItems.DropHighlight
  905.         If nHitNode Is Nothing Then Exit Sub
  906.         If nHitNode.Expanded = False Then
  907.             nHitNode.Expanded = True
  908.         End If
  909.         lCount = 0
  910.     End If
  911.     If miScrollDir <> 0 Then
  912.         If miScrollDir = -1 Then
  913.             SendMessageLong tvwItems.hwnd, WM_VSCROLL, 0, 0
  914.         Else
  915.             SendMessageLong tvwItems.hwnd, WM_VSCROLL, 1, 0
  916.         End If
  917.     End If
  918. End Sub
  919. Private Sub tvwItems_AfterLabelEdit(Cancel As Integer, NewString As String)
  920.     modData.Key = tvwItems.SelectedItem.Key
  921.     modData.Description = NewString
  922.     modData.UpdateDB tvwItems
  923.     SelectItem tvwItems.SelectedItem.Key, ctlData1
  924. End Sub
  925. Private Sub tvwItems_BeforeLabelEdit(Cancel As Integer)
  926.     If tvwItems.SelectedItem.Key = "ROOT" Then Cancel = True
  927. End Sub
  928. Private Sub tvwItems_Collapse(ByVal Node As ComctlLib.Node)
  929.     On Error GoTo vbErrHand
  930.     If Node.Key = "ROOT" Then Exit Sub
  931.     Node.Image = "CLOSED"
  932.     modData.SelectItem Node.Key, ctlData1
  933.     Exit Sub
  934. vbErrHand:
  935.     WriteError Err.Number, Err.Description, "Collapse", Now, App.Path & "\err.log"
  936.     MsgBox Err.Description, vbCritical + vbOKOnly, "Collapse"
  937. End Sub
  938. Private Sub tvwItems_Expand(ByVal Node As ComctlLib.Node)
  939.     On Error GoTo vbErrHand
  940.     If Node.Key = "ROOT" Then Exit Sub
  941.     Node.Image = "OPEN"
  942.     modData.SelectItem Node.Key, ctlData1
  943.     Exit Sub
  944. vbErrHand:
  945.     WriteError Err.Number, Err.Description, "Expand", Now, App.Path & "\err.log"
  946.     MsgBox Err.Description, vbCritical + vbOKOnly, "Expand"
  947. End Sub
  948. Private Sub tvwItems_KeyUp(KeyCode As Integer, Shift As Integer)
  949.     '// Detect key presses of Insert and Delete
  950.     Dim intPos As Integer
  951.     If KeyCode = vbKeyDelete Then
  952.         modData.Key = tvwItems.SelectedItem.Key
  953.         modData.DeleteNode tvwItems
  954.     End If
  955.     If KeyCode = vbKeyInsert Then
  956.         frmAdd.Show vbModal
  957.     End If
  958. End Sub
  959. Private Sub tvwItems_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  960.     Set mnDragNode = tvwItems.HitTest(X, Y)
  961. End Sub
  962. Private Sub tvwItems_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  963.     If mnDragNode Is Nothing Then Exit Sub
  964.     If Button = vbLeftButton Then
  965.         If mnDragNode.Key <> "ROOT" Then
  966.             '
  967.             ' Start Dragging !
  968.             '
  969.             Set tvwItems.SelectedItem = mnDragNode
  970.             tmrDragTimer.Interval = 100
  971.             tmrDragTimer.Enabled = True
  972.             tvwItems.OLEDrag
  973.         End If
  974.     Else
  975.         Set mnDragNode = Nothing
  976.     End If
  977. End Sub
  978. Private Sub tvwItems_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  979.     On Error GoTo vbErrHand
  980.     Dim blnIsRoot As Boolean
  981.     '// Shows our context menu
  982.     If tvwItems.SelectedItem Is Nothing Then Exit Sub
  983.     If Button = vbRightButton Then
  984.         blnIsRoot = (StrComp(tvwItems.SelectedItem.Index, "1", vbTextCompare) = 0)
  985.         m_cTree.Restore "TreeMenu"
  986.         m_cTree.Enabled(m_cTree.IndexForKey("ADDFAVS")) = Not (blnIsRoot)
  987.         m_cTree.Enabled(m_cTree.IndexForKey("DEL")) = Not (blnIsRoot)
  988.         m_cTree.Enabled(m_cTree.IndexForKey("REMFAVS")) = Not (blnIsRoot)
  989.         m_cTree.Enabled(m_cTree.IndexForKey("PROPS")) = Not (blnIsRoot)
  990.         If Not blnIsRoot And GetVersion = 3 Then
  991.             m_cTree.Enabled(m_cTree.IndexForKey("ADD")) = InStr(tvwItems.SelectedItem.Key, "F")
  992.             m_cTree.Enabled(m_cTree.IndexForKey("FOLDER")) = InStr(tvwItems.SelectedItem.Key, "F")
  993.             Else: If GetVersion = 2 Then m_cTree.Enabled(m_cTree.IndexForKey("FOLDER")) = False
  994.         End If
  995.         If InStr(tvwItems.SelectedItem.Key, "F") Then
  996.             m_cTree.Caption(m_cTree.IndexForKey("DEL")) = "&Delete Folder"
  997.             m_cTree.Enabled(m_cTree.IndexForKey("HTML")) = False
  998.         Else
  999.             m_cTree.Caption(m_cTree.IndexForKey("DEL")) = "&Delete Item"
  1000.             m_cTree.Enabled(m_cTree.IndexForKey("HTML")) = True
  1001.         End If
  1002.         
  1003.         If Not (Me.VBInstance Is Nothing) Then
  1004.             m_cTree.Enabled(m_cTree.IndexForKey("NEWMOD")) = True
  1005.             m_cTree.Enabled(m_cTree.IndexForKey("NEWCLS")) = True
  1006.         Else
  1007.             m_cTree.Enabled(m_cTree.IndexForKey("NEWMOD")) = False
  1008.             m_cTree.Enabled(m_cTree.IndexForKey("NEWCLS")) = False
  1009.         End If
  1010.         Call m_cTree.ShowPopupMenu(X + tvwItems.left, Y + tvwItems.tOp)
  1011.     End If
  1012.     Exit Sub
  1013. vbErrHand:
  1014.     WriteError Err.Number, Err.Description, "tvwItems_MouseUp", Now, App.Path & "\err.log"
  1015.     MsgBox Err.Description, vbCritical + vbOKOnly, "tvwItems_MouseUp"
  1016. End Sub
  1017. Private Sub tvwItems_NodeClick(ByVal Node As ComctlLib.Node)
  1018.     '// Selects our item
  1019.     On Error GoTo vbErrHand
  1020.     modData.Code = ctlData1.Code
  1021.     modData.Key = tvwItems.SelectedItem.Key
  1022.     modData.SelectItem Node.Key, ctlData1
  1023.     Exit Sub
  1024. vbErrHand:
  1025.     WriteError Err.Number, Err.Description, "NodeClick", Now, App.Path & "\err.log"
  1026.     MsgBox Err.Description, vbCritical + vbOKOnly, "NodeClick"
  1027. End Sub
  1028. Private Sub SizeControls(ByVal X As Long)
  1029.     On Error Resume Next
  1030.     picToolbar.Width = Me.ScaleWidth * 2
  1031.     picToolbar.Height = tbrMain.ToolbarHeight * 2
  1032.     tbhMain.Width = Me.ScaleWidth
  1033.     tbhMenu.Width = Me.ScaleWidth
  1034.     '--
  1035.     ' Size all controls based on the splitter bar by Chris Eastwood
  1036.     '--
  1037.     Dim lHeightOffSet As Long
  1038.     'set the width
  1039.     If X < 1500 Then X = 1500
  1040.     If X > (Me.Width - 1500) Then X = Me.Width - 1500
  1041.     If m_blnControl Then
  1042.         ctlFavourites1.Height = Me.ScaleHeight * (2 / 8)
  1043.         lHeightOffSet = ctlFavourites1.Height
  1044.     Else
  1045.         lHeightOffSet = 0
  1046.     End If
  1047.     With imgSplitter
  1048.         .left = X
  1049.         .Width = 150
  1050.         .ZOrder
  1051.     End With
  1052.     With tvwItems
  1053.         .Move ScaleLeft, picToolbar.Height, X, Me.ScaleHeight - (stbBar.Height + picToolbar.Height + lHeightOffSet)
  1054.     End With
  1055.     With ctlData1
  1056.         .Move X + 25, tvwItems.tOp, Me.ScaleWidth - (tvwItems.Width + 50), tvwItems.Height
  1057.     End With
  1058.     With ctlFavourites1
  1059.         .Move ScaleLeft, tvwItems.tOp + tvwItems.Height, ScaleWidth, lHeightOffSet
  1060.     End With
  1061.     imgSplitter.tOp = tvwItems.tOp
  1062.     imgSplitter.Height = tvwItems.Height
  1063. End Sub
  1064. Private Sub BuildMenus()
  1065.     On Error GoTo vbErrHand
  1066.     '// Builds our menus
  1067.     Dim iP(0 To 26) As Long
  1068.     '// Init the menu
  1069.     Set m_cMenu = New cPopupMenu
  1070.     With m_cMenu
  1071.         .ImageList = ilsMenu
  1072.         .hwndOwner = Me.hwnd
  1073.         .GradientHighlight = True
  1074.         .Clear
  1075.         '// Add the items
  1076.         iP(0) = .AddItem("&File", , , , , , , "mnuFileTop")
  1077.         iP(1) = .AddItem("&New Database" & vbTab & "Ctrl+N", , , iP(0), 0, , , "NEW")
  1078.         iP(2) = .AddItem("&Open Database", , , iP(0), 1, , , "OPEN")
  1079.         iP(3) = .AddItem("-", , , iP(0), , , , "SEP1")
  1080.         iP(4) = .AddItem("&Add to Favourites", , , iP(0), 2, , , "FAVOURITES")
  1081.         iP(5) = .AddItem("&Remove from Favourites", , , iP(0), 3, , , "REMOVE")
  1082.         iP(6) = .AddItem("-", , , iP(0), , , , "SEP2")
  1083.         iP(7) = .AddItem("Rename Item", , , iP(0), 4, , , "RENAME")
  1084.         iP(8) = .AddItem("-", , , iP(0), , , , "SEP3")
  1085.         iP(9) = .AddItem("E&xit", , , iP(0), , , , "EXIT")
  1086.         iP(10) = .AddItem("&Edit", , , , , , , "mnuEditTop")
  1087.         iP(11) = .AddItem("&Undo" & vbTab & "Ctrl+Z", , , iP(10), 5, , , "UNDO")
  1088.         iP(12) = .AddItem("-", , , iP(10), , , , "SEP4")
  1089.         iP(13) = .AddItem("Cu&t" & vbTab & "Ctrl+X", , , iP(10), 6, , , "CUT")
  1090.         iP(14) = .AddItem("&Copy" & vbTab & "Ctrl+C", , , iP(10), 7, , , "COPY")
  1091.         iP(15) = .AddItem("&Paste" & vbTab & "Ctrl+V", , , iP(10), 8, , , "PASTE")
  1092.         iP(16) = .AddItem("Select &All" & vbTab & "Ctrl+A", , , iP(10), , , , "SELECTALL")
  1093.         iP(17) = .AddItem("&View", , , , , , , "mnuViewTop")
  1094.         iP(18) = .AddItem("&Control Panel", , , iP(17), , True, , "CPL")
  1095.         iP(19) = .AddItem("&Properties", , , iP(17), 9, , , "PROPERTIES")
  1096.         iP(20) = .AddItem("-", , , iP(17), , , , "SEP5")
  1097.         iP(21) = .AddItem("&Options", , , iP(17), 10, , , "OPTIONS")
  1098.         iP(22) = .AddItem("&Help", , , , , , , "mnuHelpTop")
  1099.         iP(23) = .AddItem("On the &net", , , iP(22), 11, , , "NET")
  1100.         iP(24) = .AddItem("&Readme", , , iP(22), 12, , , "README")
  1101.         iP(25) = .AddItem("-", , , iP(22), , , , "SEP6")
  1102.         iP(26) = .AddItem("About...", , , iP(22), , , , "ABOUT")
  1103.         .Store "BaseMenu"
  1104.     End With
  1105.     Exit Sub
  1106. vbErrHand:
  1107.     WriteError Err.Number, Err.Description, "BuildMenus", Now, App.Path & "\err.log"
  1108.     MsgBox Err.Description, vbCritical + vbOKOnly, "BuildMenus"
  1109. End Sub
  1110. Private Sub AddQuickFind(strText As String)
  1111.     On Error GoTo vbErrHand
  1112.     Dim intFile As Integer
  1113.     Dim strFileName As String
  1114.     '// Adds a new entry to the QuickFind feature
  1115.     strFileName = App.Path & "\quickfind.log"
  1116.     intFile = FreeFile
  1117.     Open strFileName For Append As #intFile
  1118.     Print #intFile, strText
  1119.     Close #intFile
  1120.     Exit Sub
  1121. vbErrHand:
  1122.     WriteError Err.Number, Err.Description, "AddQuickFind", Now, App.Path & "\err.log"
  1123.     MsgBox Err.Description, vbCritical + vbOKOnly, "AddQuickFind"
  1124. End Sub
  1125. 'Private Function ColourComments(ByVal strText As String) As String
  1126. '    Dim intPos As Integer
  1127. '    Dim strChar As String
  1128. '    Dim blnOpenQuote As Boolean
  1129. '    '// Colours our comments green
  1130. '    '// Original code by Rod Stephens
  1131. '    For intPos = 1 To Len(strText)
  1132. '        strChar = mID$(strText, intPos, 1)
  1133. '        If strChar = """" Then
  1134. '            blnOpenQuote = Not blnOpenQuote
  1135. '        ElseIf (strChar = "'") And (Not blnOpenQuote) Then
  1136. '            Exit For
  1137. '        End If
  1138. '    Next intPos
  1139. '    If intPos <= Len(strText) Then
  1140. '        ColourComments = left$(strText, intPos - 1) & _
  1141.          '                "<font colour=#007F00>" & "'" & mID$(strText, intPos + 1) & "</font>"
  1142. '    Else
  1143. '        ColourComments = strText
  1144. '    End If
  1145. 'End Function
  1146. Private Sub QuickFind(cbo As Object)
  1147.     Dim strFile As String
  1148.     Dim intFile As Integer
  1149.     Dim strNextChar As String * 1
  1150.     Dim strLine As String
  1151.     Dim intCounter As Integer
  1152.     Dim lngRet As Long
  1153.     On Error GoTo vbErrHand
  1154.     '// Returns the QuickFind entries
  1155.     strFile = App.Path & "\quickfind.log"
  1156.     intFile = FreeFile
  1157.     If Dir$(strFile) = "" Then Exit Sub
  1158.     Open strFile For Input As #intFile
  1159.     txtTemp.Text = Input(LOF(intFile), intFile)
  1160.     Close #intFile
  1161.     For intCounter = 1 To Len(txtTemp)
  1162.         strNextChar = mID$(txtTemp, intCounter, 1)
  1163.         If strNextChar = Chr(13) Then
  1164.             cbo.AddItem strLine
  1165.             strLine = ""
  1166.         ElseIf strNextChar = Chr(10) Then
  1167.         Else
  1168.             strLine = strLine & strNextChar
  1169.         End If
  1170.     Next
  1171.     Exit Sub
  1172. vbErrHand:
  1173.     If Err.Number = 54 Then
  1174.         Close #intFile
  1175.     End If
  1176.     WriteError Err.Number, Err.Description, "QuickFind", Now, App.Path & "\err.log"
  1177.     MsgBox Err.Description, vbCritical + vbOKOnly, "QuickFind"
  1178. End Sub
  1179. Private Sub MoveDown(tvw As TreeView)
  1180.     On Error GoTo vbErrHand
  1181.     '// Moves down and level
  1182.     If tvw.SelectedItem Is Nothing Then Exit Sub
  1183.     Set m_nodNode = tvw.SelectedItem.Next
  1184.     If Not (m_nodNode Is Nothing) Then
  1185.         Set tvw.SelectedItem = m_nodNode
  1186.         modData.SelectItem m_nodNode.Key, ctlData1
  1187.     Else
  1188.         Set m_nodNode = tvw.SelectedItem.Child
  1189.         If Not (m_nodNode Is Nothing) Then
  1190.             Set tvw.SelectedItem = m_nodNode
  1191.             modData.SelectItem m_nodNode.Key, ctlData1
  1192.         End If
  1193.     End If
  1194.     Exit Sub
  1195. vbErrHand:
  1196.     WriteError Err.Number, Err.Description, "MoveDown", Now, App.Path & "\err.log"
  1197.     MsgBox Err.Description, vbCritical + vbOKOnly, "MoveDown"
  1198. End Sub
  1199. Private Sub MoveUp(tvw As TreeView)
  1200.     On Error GoTo vbErrHand
  1201.     '// Moves up a level
  1202.     If tvw.SelectedItem Is Nothing Then Exit Sub
  1203.     Set m_nodNode = tvw.SelectedItem.Previous
  1204.     If Not (m_nodNode Is Nothing) Then
  1205.         If m_nodNode.Key = "ROOT" Then Exit Sub
  1206.         Set tvw.SelectedItem = m_nodNode
  1207.         modData.SelectItem m_nodNode.Key, ctlData1
  1208.     Else
  1209.         Set m_nodNode = tvw.SelectedItem.Parent
  1210.         If Not (m_nodNode Is Nothing) Then
  1211.             Set tvw.SelectedItem = m_nodNode
  1212.             modData.SelectItem m_nodNode.Key, ctlData1
  1213.         End If
  1214.     End If
  1215.     Exit Sub
  1216. vbErrHand:
  1217.     WriteError Err.Number, Err.Description, "MoveUp", Now, App.Path & "\err.log"
  1218.     MsgBox Err.Description, vbCritical + vbOKOnly, "MoveUp"
  1219. End Sub
  1220. Public Function RecursiveCountNodes(nNode As Node, Optional bResetToZero As Boolean = False) As Long
  1221.     Dim nNodeChild As Node
  1222.     Dim iIndex As Integer
  1223.     Static lCount As Long
  1224.     If bResetToZero Then
  1225.         lCount = 0
  1226.     End If
  1227.     '// Thanks to Chris Eastwood for this
  1228.     '
  1229.     ' Get Details for item (as long as it's not the Root Item)
  1230.     '
  1231.     Set nNodeChild = nNode.Child
  1232.     '
  1233.     ' Now walk through the current parent node's children
  1234.     '
  1235.     Do While Not (nNodeChild Is Nothing)
  1236.         lCount = lCount + 1
  1237.         '
  1238.         ' If the current child node has it's own children...
  1239.         '
  1240.         RecursiveCountNodes nNodeChild, False
  1241.         '
  1242.         ' Get the current child node's next sibling
  1243.         '
  1244.         Set nNodeChild = nNodeChild.Next
  1245.     Loop
  1246.     RecursiveCountNodes = lCount
  1247. End Function
  1248. 'Private Function ReplaceString(ByVal sText As String, ByVal strFrom As String, ByVal strTo As String) As String
  1249. '    Dim intPos As Integer
  1250. '    Dim strNew As String
  1251. '    '// Original code by Rod Stephens
  1252. '    strNew = ""
  1253. '    Do
  1254. '        intPos = InStr(sText, strFrom)
  1255. '        If intPos = 0 Then Exit Do
  1256. '        strNew = left$(sText, intPos - 1) & strTo
  1257. '        sText = mID$(sText, intPos + Len(strFrom))
  1258. '    Loop
  1259. '    strNew = strNew & sText
  1260. '    ReplaceString = strNew
  1261. 'End Function
  1262. Sub ShowCPL(blnShow As Boolean)
  1263.     On Error GoTo vbErrHand
  1264.     '// Shows/Hides our control panel
  1265.     m_blnControl = blnShow
  1266.     ctlFavourites1.Visible = m_blnControl
  1267.     Form_Resize
  1268.     m_cMenu.Checked(m_cMenu.IndexForKey("CPL")) = m_blnControl
  1269.     Exit Sub
  1270. vbErrHand:
  1271.     WriteError Err.Number, Err.Description, "ShowCPL", Now, App.Path & "\err.log"
  1272.     MsgBox Err.Description, vbCritical + vbOKOnly, "ShowCPL"
  1273. End Sub
  1274. Public Function ShowFileDialog(ByVal sType As eFileDialog, ByRef sFIleName As String, ByVal sTitle As String, Optional sFilter As String) As String
  1275.     On Error GoTo vbErrHand
  1276.     '// Shows the common dialog
  1277.     '// Idea from Chris Eastwood
  1278.     If Len(sFilter) = 0 Then
  1279.         sFilter = "All Files |*.*"
  1280.     End If
  1281.     If Len(cmdDialog.InitDir) = 0 Then
  1282.         cmdDialog.InitDir = App.Path
  1283.     End If
  1284.     cmdDialog.CancelError = True
  1285.     cmdDialog.DialogTitle = sTitle
  1286.     If Len(sFIleName) > 0 Then
  1287.         cmdDialog.FileName = sFIleName
  1288.     Else
  1289.         cmdDialog.FileName = ""
  1290.     End If
  1291.     If Len(sFilter) > 0 Then
  1292.         cmdDialog.Filter = sFilter
  1293.     Else
  1294.         cmdDialog.Filter = ""
  1295.     End If
  1296.     cmdDialog.flags = cdlOFNExplorer + cdlOFNHideReadOnly
  1297.     If sType = eOpen Then
  1298.         cmdDialog.ShowOpen
  1299.     Else
  1300.         cmdDialog.flags = cmdDialog.flags + cdlOFNOverwritePrompt
  1301.         cmdDialog.ShowSave
  1302.     End If
  1303.     sFIleName = cmdDialog.FileName
  1304.     If Len(sFIleName) > 0 Then
  1305.         ShowFileDialog = sFIleName
  1306.     End If
  1307.     Exit Function
  1308. vbErrHand:
  1309.     If Err.Number = 32755 Then
  1310.         ShowFileDialog = ""
  1311.         Exit Function
  1312.     Else
  1313.         WriteError Err.Number, Err.Description, "ShowFileDialog", Now, App.Path & "\err.log"
  1314.         MsgBox Err.Description, vbCritical + vbOKOnly, "ShowFileDialog"
  1315.     End If
  1316. End Function
  1317. Private Sub ShowProgressInStatusBar(ByVal bShowProgressBar As Boolean)
  1318.     '--
  1319.     'Loads a progress bar into a status bar pannel
  1320.     'Authored by Chris Eastwood
  1321.     '--
  1322.     Dim tRC As RECT
  1323.     If bShowProgressBar Then
  1324.         '
  1325.         ' Get the size of the Panel (2) Rectangle from the status bar
  1326.         ' remember that Indexes in the API are always 0 based (well,
  1327.         ' nearly always) - therefore Panel(2) = Panel(1) to the api
  1328.         '
  1329.         '
  1330.         SendMessageAny stbBar.hwnd, SB_GETRECT, 1, tRC
  1331.         '
  1332.         ' and convert it to twips....
  1333.         '
  1334.         With tRC
  1335.             .tOp = (.tOp * Screen.TwipsPerPixelY)
  1336.             .left = (.left * Screen.TwipsPerPixelX)
  1337.             .Bottom = (.Bottom * Screen.TwipsPerPixelY) - .tOp
  1338.             .Right = (.Right * Screen.TwipsPerPixelX) - .left
  1339.         End With
  1340.         '
  1341.         ' Now Reparent the ProgressBar to the statusbar
  1342.         '
  1343.         With pgb
  1344.             SetParent .hwnd, stbBar.hwnd
  1345.             .Move tRC.left, tRC.tOp, tRC.Right, tRC.Bottom
  1346.             .Visible = True
  1347.             .Value = 0
  1348.         End With
  1349.     Else
  1350.         '
  1351.         ' Reparent the progress bar back to the form and hide it
  1352.         '
  1353.         SetParent pgb.hwnd, Me.hwnd
  1354.         pgb.Visible = False
  1355.     End If
  1356. End Sub
  1357. Public Function SourceToHTML(ByVal source_text As String) As String
  1358.     On Error GoTo vbErrHand
  1359.     Dim strBuffer As String
  1360.     Dim strHeader As String
  1361.     Dim strFooter As String
  1362.     Dim cHourGlass As CWaitCursor
  1363.     Dim strFile As String
  1364.     Dim intFile As Integer
  1365.     Dim intCount As Integer
  1366.     strHeader = GetSetting(ThisApp, "HTML", "Header", "")
  1367.     strFooter = GetSetting(ThisApp, "HTML", "Footer", "")
  1368.     intFile = FreeFile
  1369.     strFile = ShowFileDialog(eSave, "", "Output File...", "HTML Files (*.htm)|*.htm| All Files (*.*)|*.*|")
  1370.     If strFile = "" Then Exit Function
  1371.     Set cHourGlass = New CWaitCursor
  1372.     cHourGlass.SetCursor
  1373.     strBuffer = RTF2HTML(source_text, "+H", strHeader, strFooter)
  1374.     For intCount = 1 To Len(strBuffer)
  1375.         If intCount = Len(strBuffer) Then
  1376.             pgb.Value = pgb.Value + (100 - pgb.Value)
  1377.         End If
  1378.         If pgb.Value = 100 Then Exit For
  1379.         If (0 + intCount - 1) Mod Int(100 / 200 + 1) = 0 Then
  1380.             pgb.Value = (0 + intCount - 1)
  1381.             stbBar.Panels(1).Text = "Converting..."
  1382.             DoEvents
  1383.         End If
  1384.     Next
  1385.     pgb.Value = 0
  1386.     stbBar.Panels(1).Text = ""
  1387.     Open strFile For Output As #intFile
  1388.     Write #intFile, strBuffer
  1389.     Close #intFile
  1390.     MsgBox "Code outputted to HTML file at " & strFile
  1391.     Exit Function
  1392. vbErrHand:
  1393.     WriteError Err.Number, Err.Description, "SourceToHTML", Now, App.Path & "\err.log"
  1394.     MsgBox Err.Description, vbCritical + vbOKOnly, "SourceToHTML"
  1395. End Function
  1396. Private Sub TreeRedraw(ByVal lHwnd As Long, ByVal bRedraw As Boolean)
  1397.     '--
  1398.     ' Utility Routine for TreeRedraw on/of by Chris Eastwood
  1399.     '--
  1400.     SendMessageLong lHwnd, WM_SETREDRAW, bRedraw, 0
  1401. End Sub
  1402. Sub BuildTreeMenu()
  1403.     On Error GoTo vbErrHand
  1404.     '// Builds our treeview's menu
  1405.     Dim lngExport As Long
  1406.     '// Init the menu
  1407.     Set m_cTree = New cPopupMenu
  1408.     With m_cTree
  1409.         .ImageList = ilsMenu
  1410.         .hwndOwner = Me.hwnd
  1411.         .GradientHighlight = True
  1412.         .Clear
  1413.         '// Add items
  1414.         .AddItem "New &Item", , , , 0, , , "ADD"
  1415.         .AddItem "New &Folder", , , , 13, , , "FOLDER"
  1416.         .AddItem "Delete Item", , , , 14, , , "DEL"
  1417.         .AddItem "-"
  1418.         .AddItem "Import Item", , , , 15, , , "IMPORT"
  1419.         lngExport = .AddItem("Export Item", , , , 16, , , "EXPORT")
  1420.         .AddItem "DCB File", , , lngExport, , , , "DCB"
  1421.         .AddItem "HTML File", , , lngExport, 11, , , "HTML"
  1422.         .AddItem "New Module in VB", , , lngExport, 27, , , "NEWMOD"
  1423.         .AddItem "New Class in VB", , , lngExport, 28, , , "NEWCLS"
  1424.         .AddItem "-"
  1425.         .AddItem "Add Favourite", , , , 2, , , "ADDFAVS"
  1426.         .AddItem "Remove Favourites", , , , 3, , , "REMFAVS"
  1427.         .AddItem "-"
  1428.         .AddItem "&Properties", , , , 9, , , "PROPS"
  1429.         .Store "TreeMenu"
  1430.     End With
  1431.     Exit Sub
  1432. vbErrHand:
  1433.     WriteError Err.Number, Err.Description, "BuildTreeMenu", Now, App.Path & "\err.log"
  1434.     MsgBox Err.Description, vbCritical + vbOKOnly, "BuildTreeMenu"
  1435. End Sub
  1436. Sub InitToolbar()
  1437.     On Error GoTo vbErrHand
  1438.     Dim intCount As Integer
  1439.     '// Sets up our toolbar/rebar/cool menu
  1440.     DoEvents
  1441.     BuildMenus
  1442.     tbrMenu.CreateFromMenu m_cMenu
  1443.     With tbhMenu
  1444.         .BorderStyle = etbhBorderStyleNone
  1445.         .MDIToolbar = False
  1446.         .Capture tbrMenu
  1447.     End With
  1448.     With tbrMain
  1449.         .ImageSource = CTBExternalImageList
  1450.         .SetImageList ilsMenu
  1451.         .CreateToolbar 16, , , True
  1452.         .AddButton "UP", 17, , , , , "UP"
  1453.         .AddButton "DOWN", 18, , , , , "DOWN"
  1454.         .AddButton "", , , , , CTBSeparator, "SEP1"
  1455.         .AddButton "New Item", 0, , , , , "NEW"
  1456.         .AddButton "Save Current Code", 19, , , , , "SAVE"
  1457.         .AddButton "Syntax Highlight", 20, , , , , "COLOUR"
  1458.         .AddButton "Delete Item", 14, , , , , "DELETE"
  1459.         .AddButton "Find", 21, , , , , "FIND"
  1460.         .AddButton "Add to Favourites", 2, , , , , "ADDFAVS"
  1461.         .AddButton , , , , , CTBSeparator
  1462.         .AddButton "Cut", 6, , , , , "CUT"
  1463.         .AddButton "Copy", 7, , , , , "COPY"
  1464.         .AddButton "Paste", 8, , , , , "PASTE"
  1465.         .AddButton "Select All", 22, , , , , "SELECTALL"
  1466.         .AddButton "Print", 23, , , , , "PRINT"
  1467.     End With
  1468.     With tbhMain
  1469.         .BorderStyle = etbhBorderStyleNone
  1470.         .Width = Me.ScaleWidth
  1471.         .Height = tbrMain.ToolbarHeight * Screen.TwipsPerPixelY
  1472.         .Capture cboFind
  1473.         .Capture tbrMain
  1474.     End With
  1475.     With rbrMain
  1476.         .Position = erbPositionTop
  1477.         .CreateRebar picToolbar.hwnd
  1478.         .AddBandByHwnd tbhMenu.hwnd, , , , "MENU"
  1479.         .AddBandByHwnd tbhMain.hwnd, , , , "MAINBAR"
  1480.         .BandChildMinWidth(0) = tbrMenu.ToolbarWidth
  1481.         .BandChildMinWidth(1) = tbrMain.ToolbarWidth
  1482.     End With
  1483.     BuildTreeMenu
  1484.     Exit Sub
  1485. vbErrHand:
  1486.     WriteError Err.Number, Err.Description, "InitToolbar", Now, App.Path & "\err.log"
  1487.     MsgBox Err.Description, vbCritical + vbOKOnly, "InitToolbar"
  1488. End Sub
  1489. Sub GetSettings()
  1490.     Dim sWHeight As String
  1491.     Dim sWWidth As String
  1492.     Dim sWLeft As String
  1493.     Dim sWTop As String
  1494.     Dim sSizes As String
  1495.     Dim sTab As String
  1496.     On Error GoTo vbErrHand
  1497.     '// Retrieve the settings and apply appropiatly
  1498.     sSizes = GetSetting(ThisApp, "General", "Sizes", "0")
  1499.     If sSizes = "1" Then 'Show sizes
  1500.         sWHeight = GetSetting(ThisApp, "General", "WindowHeight", "")
  1501.         sWWidth = GetSetting(ThisApp, "General", "WindowWidth", "")
  1502.         sWLeft = GetSetting(ThisApp, "General", "WindowLeft", "")
  1503.         sWTop = GetSetting(ThisApp, "General", "WindowTop", "")
  1504.         Me.Height = sWHeight
  1505.         Me.Width = sWWidth
  1506.         Me.left = sWLeft
  1507.         Me.tOp = sWTop
  1508.     End If
  1509.     m_blnControl = GetSetting(ThisApp, "General", "ShowControl", True)
  1510.     Exit Sub
  1511. vbErrHand:
  1512.     WriteError Err.Number, Err.Description, "GetSettings", Now, App.Path & "\err.log"
  1513.     MsgBox Err.Description, vbCritical + vbOKOnly, "GetSettings"
  1514. End Sub
  1515. Private Sub SaveSettings()
  1516.     '// Save the height, width, top and left settings
  1517.     Dim sSizes As String
  1518.     On Error GoTo vbErrHand
  1519.     sSizes = GetSetting(ThisApp, "General", "Sizes", "0")
  1520.     If sSizes = "1" Then
  1521.         If Me.WindowState <> vbMinimized Then
  1522.             SaveSetting ThisApp, "General", "WindowHeight", Me.Height
  1523.             SaveSetting ThisApp, "General", "WindowWidth", Me.Width
  1524.             SaveSetting ThisApp, "General", "WindowLeft", Me.left
  1525.             SaveSetting ThisApp, "General", "WindowTop", Me.tOp
  1526.         End If
  1527.     End If
  1528.     If m_blnControl = True Then
  1529.         SaveSetting ThisApp, "General", "ShowControl", "1"
  1530.     Else
  1531.         SaveSetting ThisApp, "General", "ShowControl", "0"
  1532.     End If
  1533.     SaveSetting ThisApp, "General", "DBPath", modData.DBName
  1534.     Exit Sub
  1535. vbErrHand:
  1536.     WriteError Err.Number, Err.Description, "SaveSettings", Now, App.Path & "\err.log"
  1537.     MsgBox Err.Description, vbCritical + vbOKOnly, "SaveSettings"
  1538. End Sub
  1539. Public Sub UnloadMe()
  1540.    ' On Error GoTo vbErrHand
  1541.     If m_blnDBLoaded = False Then Exit Sub
  1542.     SaveSettings
  1543.     tvwItems.SetFocus
  1544.     DoEvents
  1545.     modData.SelectItem "ROOT", ctlData1
  1546.     ctlData1.Terminate
  1547.     ctlFavourites1.Terminate
  1548.     DoEvents
  1549.     '// Backup/Compact/Restore
  1550.     modData.DoActions
  1551.     Exit Sub
  1552. vbErrHand:
  1553.     WriteError Err.Number, Err.Description, "UnloadMe", Now, App.Path & "\err.log"
  1554.     MsgBox Err.Description, vbCritical + vbOKOnly, "UnloadMe"
  1555.     Resume Next
  1556. End Sub
  1557. Private Sub tvwItems_OLECompleteDrag(Effect As Long)
  1558.     Screen.MousePointer = vbDefault
  1559.     tmrDragTimer.Enabled = False
  1560. End Sub
  1561. Private Sub tvwItems_OLEDragDrop(Data As ComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
  1562.     '
  1563.     ' Handle the dragging and-a dropping of treeview nodes here
  1564.     '
  1565.     Dim sTmpStr As String
  1566.     Dim oTargetNode As Node
  1567.     Dim sParentKey As String
  1568.     Dim sKey As String
  1569.     Dim oOldParentNode As Node
  1570.     On Error Resume Next
  1571.     '
  1572.     ' Check whether the clipboard data is in our special defined format
  1573.     '
  1574.     sTmpStr = Data.GetFormat(miClipBoardFormat)
  1575.     If Err Or sTmpStr = "False" Then    ' it's not, so don't allow dropping
  1576.         Set mnDragNode = Nothing
  1577.         Set tvwItems.DropHighlight = Nothing
  1578.         Err.Clear
  1579.         Effect = vbDropEffectNone
  1580.         Exit Sub
  1581.     End If
  1582.     On Error GoTo vbErrorHandler
  1583.     If mnDragNode Is Nothing Then
  1584.         Set mnDragNode = Nothing
  1585.         Set tvwItems.DropHighlight = Nothing
  1586.         Effect = vbDropEffectNone
  1587.         Exit Sub
  1588.     End If
  1589.     Set oTargetNode = tvwItems.DropHighlight
  1590.     '
  1591.     If oTargetNode Is Nothing Then
  1592.         Set mnDragNode = Nothing
  1593.         Set tvwItems.DropHighlight = Nothing
  1594.         Effect = vbDropEffectNone
  1595.         Exit Sub
  1596.     End If
  1597.     If InStr(oTargetNode.Key, "C") Then
  1598.         MsgBox "You cannot add an item to an existing item, only a folder object."
  1599.         Set mnDragNode = Nothing
  1600.         Set tvwItems.DropHighlight = Nothing
  1601.         Effect = vbDropEffectNone
  1602.         Exit Sub
  1603.     End If
  1604.     Set oOldParentNode = mnDragNode.Parent
  1605.     Set mnDragNode.Parent = oTargetNode
  1606.     '
  1607.     ' Here's where we handle the drop - don't forget that we have to reparent
  1608.     ' our data objects to point to the new data object (or 0 if root)
  1609.     '
  1610.     sParentKey = oTargetNode.Key
  1611.     If sParentKey = "ROOT" Then
  1612.         sParentKey = "0"
  1613.     Else
  1614.         sParentKey = Right$(sParentKey, Len(sParentKey) - 1)
  1615.     End If
  1616.     sKey = mnDragNode.Key
  1617.     sKey = Right$(sKey, Len(sKey) - 1)
  1618.     '
  1619.     'Update the database
  1620.     '
  1621.     modData.ParentKey = sParentKey
  1622.     modData.Key = sKey
  1623.     modData.UpdateKey
  1624.     Set tvwItems.DropHighlight = Nothing
  1625.     Set mnDragNode = Nothing
  1626.     tmrDragTimer.Enabled = False
  1627.     If oTargetNode.Key <> "ROOT" Then
  1628.         oTargetNode.ExpandedImage = "OPEN"
  1629.     End If
  1630.     If oOldParentNode.Children <= 1 And oOldParentNode.Key <> oTargetNode.Key Then
  1631.         If oOldParentNode.Key <> "ROOT" Then
  1632.         End If
  1633.     End If
  1634.     Exit Sub
  1635. vbErrorHandler:
  1636.     Set mnDragNode = Nothing
  1637.     Set tvwItems.DropHighlight = Nothing
  1638.     '
  1639.     ' This will more than likely be 'would cause a loop' or whatever
  1640.     '
  1641.     MsgBox Err.Description, , App.ProductName
  1642.     Effect = vbDropEffectNone
  1643. End Sub
  1644. Private Sub tvwItems_OLEDragOver(Data As ComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)
  1645.     Dim sTmpStr As String
  1646.     Dim nTargetNode As Node
  1647.     On Error Resume Next
  1648.     '
  1649.     ' First check that we allow this type of data to be dropped here
  1650.     '
  1651.     sTmpStr = Data.GetFormat(miClipBoardFormat)
  1652.     If Err Or sTmpStr = "False" Then
  1653.         Err.Clear
  1654.         Effect = vbDropEffectNone
  1655.         Exit Sub
  1656.     End If
  1657.     Set nTargetNode = tvwItems.HitTest(X, Y)
  1658.     If nTargetNode Is Nothing Then
  1659.         Set tvwItems.DropHighlight = Nothing
  1660.         Exit Sub
  1661.     End If
  1662.     If nTargetNode.Key = mnDragNode.Key Then
  1663.         Set tvwItems.DropHighlight = Nothing
  1664.         Effect = vbDropEffectNone
  1665.     Else
  1666.         Set tvwItems.DropHighlight = nTargetNode
  1667.     End If
  1668.     If Y > 0 And Y < 300 Then
  1669.         miScrollDir = -1
  1670.     ElseIf (Y < tvwItems.Height) And Y > (tvwItems.Height - 500) Then
  1671.         miScrollDir = 1
  1672.     Else
  1673.         miScrollDir = 0
  1674.     End If
  1675. End Sub
  1676. Private Sub tvwItems_OLEStartDrag(Data As ComctlLib.DataObject, AllowedEffects As Long)
  1677.     Dim byt() As Byte
  1678.     '
  1679.     ' Place the key of the dragged item into the clipboard in our own format
  1680.     ' declared in GetClipboardFormat api
  1681.     '
  1682.     AllowedEffects = vbDropEffectMove
  1683.     byt = mnDragNode.Key
  1684.     Data.SetData byt, miClipBoardFormat
  1685. End Sub
  1686.